package com.zengqingfa.springboot.validation.demo.controller;

import com.zengqingfa.springboot.validation.demo.entity.UserSaveDto;
import com.zengqingfa.springboot.validation.demo.entity.UserSaveReq;
import com.zengqingfa.springboot.validation.demo.entity.UserSaveReq2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.ConstraintViolation;
import javax.validation.Valid;
import java.util.Set;


@RestController
@RequestMapping("/user6")
@Slf4j
public class UserRest6 {



    // 编程式校验
    @PostMapping("/create")
    public String testExtendsValidate(@RequestBody @Valid UserSaveReq user) {
        UserSaveReq2 req=new UserSaveReq2();
        BeanUtils.copyProperties(user,req);
        System.out.println(req);
        return "save success";
    }


}
